﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace Krile.Kernel.Control.Surface
{
    public interface IMouseControllable
    {
        Bridges.IForm ParentForm { get; set; }

        /// <summary>
        /// 指定したポイントはこのアイテム内に含まれるかチェックします。
        /// </summary>
        /// <param name="position">チェックするポイント</param>
        /// <returns>含まれるならtrue</returns>
        bool HitTest(Point position);

        string HelptipText { get; }

        void OnMouseOver(object sender, ChainMouseEventArgs e);
        void OnMouseMove(object sender, ChainMouseEventArgs e);
        void OnMouseEnter(object sender, ChainMouseEventArgs e);
        void OnMouseLeave(object sender, ChainMouseEventArgs e);
        void OnMouseClick(object sender, ChainMouseEventArgs e);
        void OnMouseDoubleClick(object sender, ChainMouseEventArgs e);
        void OnMouseDown(object sender, ChainMouseEventArgs e);
        void OnMouseUp(object sender, ChainMouseEventArgs e);
    }

    public static class HitTestExtender
    {
        /// <summary>
        /// Do hittest
        /// </summary>
        /// <param name="rect">target rectangle</param>
        /// <param name="position">target position</param>
        /// <returns>if hit, return true</returns>
        public static bool HitTest(this Rectangle rect, Point position)
        {
            return ((rect.Left <= position.X && position.X <= rect.Right) &&
                    (rect.Top <= position.Y && position.Y <= rect.Bottom));
        }
    }
}
